<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>立即消费</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<!--页面样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_jiesuan.css">
<!--页面样式结束--
<!--公共JS开始-->
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--公共JS结束-->
<!--数据列表插件开始-->
<link href="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.ui.position.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.js"></script>
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Css/etgrid.css">
<script src="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Js/etgrid.js"></script>
<!--数据列表插件结束-->
<!--滑动门插件开始-->
<script src="{$NOW_THEME_URL}/Assets/Plugins/EtTab/Js/ettab.js"></script>
<!--滑动门插件结束-->
<script src="{$NOW_THEME_URL}/Assets/Plugins/Datepicker/wdatePicker.js"></script>
<style type="text/css">
	body {
		overflow:hidden;
	}
</style>
</head>

<body>
	<div class="yhlist clearfix">
		<div class="table_box1">
				<table cellpadding="0" cellspacing="0" class="module_form" width="100%">
					<input type="hidden" id="oldid" value="{$detail.id}">
					<tr>
						<th class="left"><label for="yfPrice">应付金额：</label></th>
						<td class="left">
							<input name="orderfee" value="{$detail.totalfee}" type="text" id="orderfee" class="form_ele_text width_200" readonly>
						</td>
					</tr>
					<tr>
						<th class="left"><label for="yfyj">已付押金：</label></th>
						<td class="left">
							<input name="rent" value="{$detail.rent}" type="text" id="rent" class="form_ele_text width_200" readonly>
						</td>
					</tr>
					<tr>
						<th class="left"><label for="sfPrice">实付金额：</label></th>
						<td class="left">
							<input name="totalfee" value="{$detail['totalfee']-$detail['rent']}" type="text" id="totalfee" class="form_ele_text width_200" readonly>
						</td>
					</tr>
					<tr>
						<td colspan="4" class="jctitle">支付方式&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="payment" id="Cash"  value="Cash" checked>现金支付&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="payment" id="Bank"  value="Bank">银行卡支付&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="payment" id="Other" value="Other">其他&nbsp;&nbsp;&nbsp;&nbsp;
						</td>
					</tr>
					<tr>
						<td colspan="4">
							<table id="paymentType" style="display:none">
								<tr>
									<th class="left"><label for="zfmethod">现金支付：</label></th>
									<td class="left">
										<input name="payment[Cash]" id="CashPay" type="text" class="form_ele_text width_200">元
									</td>
								</tr>
								<tr>
									<th class="left"><label for="card">银行卡支付：</label></th>
									<td class="left">
										<input name="payment[Bank]" type="text" id="BankPay" class="form_ele_text width_200">元
										
										<input name="" type="text" id="zfmethod" class="form_ele_text width_200 inputright" value="" placeholder="请输入银行卡号" >
									</td>
								</tr>
								<tr>
									<th class="left"><label for="other">其他：</label></th>
									<td class="left">
										<input name="payment[Other]" type="text" id="OtherPay" class="form_ele_text width_200">元
										<input name="content" type="text" id="content" class="form_ele_text width_200 inputright" value="" placeholder="请输入备注" >
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td class="zhaoling" colspan="4">
							实收：<input type="text" name="payMoney" id="payMoney" class="form_ele_text widht_100 inputright">
							找零：<em id="zhaoling">0</em><em>元</em>
						</td>
					</tr>
					<tr>
						<td class="print"><input name="" type="checkbox" value="">自动打印小票</td>
						<td class="print"><label for="stime">消费时间：</label><input value="{:date('Y-m-d H:i:s')}" type="text" id="d411 stime" class="form_ele_text width_200 Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd H:m:s'})"></td>
					</tr>
				</table>
		</div>
		<div class="xiaofei">
			<a class="form_ele_submit">确定</a>
		</div>
	</div>
</body>
<script type="text/javascript">
	//表格隔行换色
	$('.module_form tr:odd').addClass('odd');
	$('.module_form tr:even').addClass('even');
	
	$(function(){
		//确认支付
		$(".form_ele_submit").on('click',function(){
			
			var tipsObj  = windowApi.lhgdialog.tips('正在提交数据...',10,etIcon.loading);
			var postData = {};
			
			postData.payment  = $("input[name='payment']").val();  //支付方式
			postData.total    = parseFloat($('#totalfee').val());  //应付金额
			postData.payMoney = $("#payMoney").val(); //实付总金额
			postData.CashPay  = $("#CashPay").val();
			postData.BankPay  = $("#BankPay").val();
			postData.OtherPay = $("#OtherPay").val();
			postData.oldid    = $("#oldid").val();
			
			$.post("{:U('Sell/payment')}", postData ,function(data){
				frameApi.close(); //关闭当前窗口
				if(data.status==1){
					windowApi.lhgdialog.tips('支付成功！',1,etIcon.success);
				}else{
					windowApi.lhgdialog.tips(data.info,2,etIcon.error);
				}
			}, "json");
		})
		
		//现金付款
		$('#payMoney').change(function(){
			var total = parseFloat($('#totalfee').val());  //应付金额
			var money = parseFloat($(this).val()); 
			var price = parseFloat(money-total);
			var total = parseFloat($('#totalfee').val());  //应付金额
			
			if(money<total){
				alert("实付金额不能小于应付金额");
				$(this).val('');
				$('#zhaoling').html('');
			}else{
				$('#zhaoling').html(price);
			}
		});
		
		//显示隐藏其他支付方式
		$("input[name='payment']").click(function(){
			var total   = parseFloat($('#totalfee').val());  //应付金额
			var payment = $(this).val();  //支付方式
			
			if(payment=='Other'){
				$("#paymentType").show();
			}else{
				$("#paymentType").hide();
			}
			
			//选择银行卡支付时，默认实收金额为订单应付金额
			if(payment=="Bank"){
				$("#payMoney").val(total);
			}
		});
		
		//填写现金支付金额时
		$("#CashPay").change(function(){
			 changePayMoney();
		})
		
		//填写银行卡支付金额时
		$("#BankPay").change(function(){
			changePayMoney(); 
		})
		
		//填写其他支付金额时
		$("#OtherPay").change(function(){
			changePayMoney(); 
		})
	})
	
	function changePayMoney(){
		
		var total      = parseFloat($("#totalfee").val());  //应付金额
		var cashMoney  = parseFloat($("#CashPay").val());   //现金支付金额
		var bankMoney  = parseFloat($("#BankPay").val());   //银行卡支付金额
		var otherMoney = parseFloat($("#OtherPay").val());   //其他支付金额
		
		cashMoney  = cashMoney?parseFloat(cashMoney):0;
		bankMoney  = bankMoney?parseFloat(bankMoney):0;
		otherMoney = otherMoney?parseFloat(otherMoney):0;
		
		var totalMoney = cashMoney+bankMoney+otherMoney;
		var surplus    = totalMoney-total;
		
		if(surplus>0){
			$("#zhaoling").html(surplus);
		}else{
			$("#zhaoling").html("0");
		}
		
		$("#payMoney").val(totalMoney);
	}
</script>
</html>
